package com.cardrive.entity;

import com.cardrive.R;
import com.cardrive.util.Sprite;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Car {

	private Engine engine;

	private Axis frontalAxis;
	private Axis roarAxis;

	private Sprite spCar;

	public Car(Context context, Engine engine, int x, int y) {

		this.engine = engine;

		spCar = new Sprite(context, R.drawable.car1, x, y);

		frontalAxis = new Axis(context, x, y, spCar.getWidth());
		roarAxis = new Axis(context, x + spCar.getHeight(), y, spCar.getImage()
				.getWidth());
	}

	public void render(Canvas canvas, Paint paint) {

		if (spCar != null) {
			
			spCar.x = (int) engine.currentPosition.x;
			spCar.y = (int) engine.currentPosition.y;
			
			spCar.render(canvas, paint);
		}
		
		frontalAxis.render(canvas, paint);
		roarAxis.render(canvas, paint);
	}

	public Engine getEngine() {
		return engine;
	}

	public void setEngine(Engine engine) {
		this.engine = engine;
	}

}
